﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class View_WMG_WMG007 : ViewMatrix
{
    protected void Page_Load(object sender, EventArgs e)
    {
        criteriaList = new string[] { "Criteria", "type" };
        limit();
        Title = "基金銷量分析表";
        serviceName = "MISAPP.Classify.Service.Service_WMG007";
        lblResult.Text = "";
    }

    protected void btn_ExecuteClick(object sender, EventArgs e)
    {
        if (!verify(null))
        {
            return;
        }
        Button btn = sender as Button;
        if (!btn.Text.Equals("Execute"))
        {
            //Page.Items.Add("topten", true);
            HttpContext.Current.Items.Add("topten", true);
            //Context
        }
        execute();        
        Server.Transfer("WMG007_1.aspx");
    }

    protected void execute()
    {
        string[] ym = { txtYM1.Text, txtYM2.Text };
        Session["Criteria"] = ym;
        Session["type"] = string.Empty;
    }

    private bool verify(object p_obj)
    {
        bool ok = true;
        if (!Utility.IsDateYM(txtYM1.Text))
        {
            ok = false;
        }

        if (p_obj == null)
        {
            if (!Utility.IsDateYM(txtYM2.Text))
            {
                ok = false;
            }
        }
        

        if (ok.Equals(false))
        {
            lblResult.Text = "請輸入YYYYMM！";
        }

        return ok;
    }

}
